#pragma once

#include <pthread.h>

class LockGuard
{
public:
    LockGuard(pthread_mutex_t *lock):lock_(lock) //上锁
    {
        pthread_mutex_lock(lock_);
    }
    ~LockGuard()   //开锁
    {
        pthread_mutex_unlock(lock_);
    }
private:
    pthread_mutex_t *lock_; 
};